package com.test.springai.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * Created with IntelliJ IDEA.
 *
 * @description:
 * @author: liuziyang
 * @since: 8/29/25 4:37 PM
 * @modifiedBy:
 * @version: 1.0
 */
@RestController
public class McpController {
  private final ChatClient chatClient;

  public McpController(ChatClient chatClient) {
    this.chatClient = chatClient;
  }

  @GetMapping(value = "/stream", produces = "text/html;charset=UTF-8")
  public Flux<String> stream(@RequestParam(value = "msg", defaultValue = "你是谁") String msg) {
    return chatClient.prompt().user(msg).stream().content();
  }
}
